﻿/// <reference path="jquery-1.7.1-vsdoc.js" />

function inviteTeam(targetuid)
{
    $.ajax(
    {
        url: "/Server/InviteTeam.ashx",
        data: { "targetuid": targetuid },
        cache: false,
        type: "POST",
        success: function (data, textStatus, jqXHR)
        {
            // eval("data = " + data);
            if (data.code == 1)
            {
                alert("您的邀请已发送，您将与最先接受邀请的宝宝组成宝宝帮。如果3天内未成功组队，系统将随机为您组队。");
            }
            else
            {
                alert(data.message);
            }
        },
        error: function ()
        {
            alert("系统错误");
        }
    });
}

function rejectTeam(shortmsgid)
{
    if (!confirm("如果在注册后3天内未成功组队，系统将随机为您组队"))
    {
        return;
    }
    $.ajax(
    {
        url: "/Server/RejectTeam.ashx",
        data: { "shortmsgid": shortmsgid },
        cache: false,
        type: "POST",
        success: function (data, textStatus, jqXHR)
        {
            // eval("data = " + data);
            if (data.code == 1)
            {
                alert('已拒绝其组队邀请');
                window.location.reload();
            }
            else
            {
                alert(data.message);
            }
        },
        error: function ()
        {
            alert("系统错误");
        }
    });
}


function acceptTeam(shortmsgid)
{
    if (!confirm("与TA结成宝宝帮后，将不能再与其他宝宝结对哦！"))
    {
        return;
    }
    $.ajax(
    {
        url: "/Server/AcceptTeam.ashx",
        data: { "shortmsgid": shortmsgid },
        cache: false,
        type: "POST",
        success: function (data, textStatus, jqXHR)
        {
            // eval("data = " + data);
            if (data.code == 1)
            {
                alert('组队成功');
                window.location.reload();
            }
            else
            {
                alert(data.message);
            }
        },
        error: function ()
        {
            alert("系统错误");
        }
    });
}



function voteTeam(teamid, ctrl) {
    
    alert("对不起，投票已经结束");

    $.ajax(
    {
        url: "/Server/voteTeam.ashx",
        data: { "teamid": teamid },
        cache: false,
        type: "POST",
        success: function (data, textStatus, jqXHR)
        {
            // eval("data = " + data);
            if (data.code == 1)
            {
                alert('感谢您的投票');
                $(ctrl).html(data.attach);
            }
            else
            {
                alert(data.message);
            }
        },
        error: function ()
        {
            alert("系统错误");
        }
    });
}

function addComment(content)
{
    $.ajax(
    {
        url: "/Server/AddComment.ashx",
        data: { "content": content },
        cache: false,
        type: "POST",
        success: function (data, textStatus, jqXHR)
        {
            // eval("data = " + data);
            if (data.code == 1)
            {
                // alert('留言成功');
                window.location.reload();
                // $(ctrl).html(data.attach);
            }
            else
            {
                alert(data.message);
            }
        },
        error: function ()
        {
            alert("系统错误");
        }
    });
}